Repository navigation
Conversation
Documentation build overview
145 files changed ·
|
…rtifact paths alphabetically in pyproject.toml
| """Export translated singular JavaScript messages from the compiled catalog.""" | ||
| mofile = pofile.with_suffix(".mo") | ||
| jsfile = pofile.with_suffix(".js") | ||
| if not mofile.exists(): | ||
| jsfile.unlink(missing_ok=True) | ||
| return |
There was a problem hiding this comment.
We could simplify this function to only read the .po file, and skip the fuzzy/untranslated messages, rather than also reading the compiled .mo file?
| """Export translated singular JavaScript messages from the compiled catalog.""" | |
| mofile = pofile.with_suffix(".mo") | |
| jsfile = pofile.with_suffix(".js") | |
| if not mofile.exists(): | |
| jsfile.unlink(missing_ok=True) | |
| return | |
| """Export translated singular JavaScript messages from the catalog.""" | |
| jsfile = pofile.with_suffix(".js") |
There was a problem hiding this comment.
Thanks for suggestion, applied. On the other hand using .mo makes us reusing the same configuration of catalog compilation, but it's not worth the complication probably.
| with mofile.open("rb") as f: | ||
| compiled = read_mo(f) |
There was a problem hiding this comment.
| with mofile.open("rb") as f: | |
| compiled = read_mo(f) |
| compiled = read_mo(f) | ||
| messages = {} | ||
| for message in source: | ||
| if not isinstance(message.id, str): |
There was a problem hiding this comment.
| if not isinstance(message.id, str): | |
| if not isinstance(message.id, str) or message.fuzzy or not message.string: |
| translation = compiled.get(message.id) | ||
| if translation is not None and translation.string: | ||
| messages[message.id] = translation.string |
There was a problem hiding this comment.
| translation = compiled.get(message.id) | |
| if translation is not None and translation.string: | |
| messages[message.id] = translation.string | |
| messages[message.id] = message.string |
| import tomllib | ||
| from pathlib import Path | ||
|
|
||
| from babel.messages.mofile import read_mo |
There was a problem hiding this comment.
| from babel.messages.mofile import read_mo |
|
Thanks for doing the work @m-aciek! I should have time tomorrow for a review :) |
| compiled = read_mo(f) | ||
| messages = {} | ||
| for message in source: | ||
| if not isinstance(message.id, str): |
There was a problem hiding this comment.
| if not isinstance(message.id, str): | |
| if message.pluralizable: |
| compiled = read_mo(f) | ||
| messages = {} | ||
| for message in source: | ||
| if not isinstance(message.id, str): |
There was a problem hiding this comment.
Do we want to warn/raise for ngettext/pgettext or just silently skip them?
There was a problem hiding this comment.
I've added support for ngettext in fb80b82 by using addTranslations instead of raw dictionary. pgettext is not supported by extraction edit: JS gettext runtime, so it should be not worth to warn. Thanks for the review.
Affirm-Session: 01a20a8a-1869-7c52-8e68-246dde4499c5
Affirm-Session: 01a20a8a-1869-7c52-8e68-246dde4499c5
Alternative to #337.
Add and mount missing JS translations catalog. Extraction was/is working correctly.